# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Sergej Pupykin

_name=vde-2
pkgname=vde2
pkgver=2.3.3
pkgrel=4
pkgdesc="Virtual Distributed Ethernet for emulators like qemu"
arch=(loong64 x86_64)
url="https://github.com/virtualsquare/vde-2"
license=(
  GPL-2.0-or-later
  LGPL-2.1-or-later
)
depends=(glibc)
makedepends=(
  libpcap
  wolfssl
)
provides=(
  libvdehist.so
  libvdemgmt.so
  libvdeplug.so
  libvdesnmp.so
)
source=($pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('d0495aa700984dcc82f85cf7c8125cc10505a8a077fceec45b7fd2bec9c389966381682842e886469fa49239badd9442403d091c2ae5282685085e8262396387')
b2sums=('e3ed7423edc03a6af09967484613c0e2a701f74a4323eeab720cabe9a899120023425527054662ee1dbd207327b7e6dd375bceb4999fd708666df13c08acf348')

prepare() {
  cd $_name-$pkgver
  autoreconf -fiv
}

build() {
  local configure_options=(
    --enable-experimental
    --libexecdir=/usr/lib/$pkgname
    --prefix=/usr
    --sbindir=/usr/bin
    --sysconfdir=/etc
  )

  cd $_name-$pkgver
  ./configure "${configure_options[@]}"
  make V=1
}

package() {
  depends+=(
    libpcap libpcap.so
    wolfssl libwolfssl.so
  )

  make DESTDIR="$pkgdir" install -C $_name-$pkgver
  install -vDm 644 $_name-$pkgver/{README,Changelog,doc/{README.*,*-HOWTO}} -t "$pkgdir/usr/share/doc/$pkgname/"
}
